Get premium membership and access questions with answers, video lessons as well as revision papers.

What will be the output of following program ? 1 2 3 4 5 6 7 #include void main() { char cnt=0; for(;cnt++;printf("%d",cnt)) ; printf("%d",cnt); }

      

What will be the output of following program ?
1
2
3
4
5
6
7
#include
void main()
{
char cnt=0;
for(;cnt++;printf("%d",cnt)) ;
printf("%d",cnt);
}

  

Answers


kinyua
Before entering into the for loop the CHECK CONDITION is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).
monica20 answered the question on February 24, 2018 at 16:53


Next: What will be the output of following program ? 1 2 3 4 5 6 7 8 #include < stdio.h > void main() { unsigned char var=0; for(var=0;var<=255;var++) ...
Previous: What will be the output of following program ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include void main() { int i=1; while (i<=5) { ...

View More Computer Science Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions